package Interface;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class panelJulien extends JPanel implements ActionListener{

	private static final long serialVersionUID = 1L;
	private JLabel jLabelAbscisse = null;
	private JLabel jLabelOrdonnee = null;
	private JComboBox jListAbscisse = null;
	private JComboBox jListOrdonnee = null;
	
	private Object[] listeAbscisseValeurs  = new Object[]{"Genre","Name","Artist","Album_Artist","Album","Grouping","Kind","Date_Modified","Date_Added","Track_Type"} ;
	private Object[] listeAbscisseOrdonnee = new Object[]{"Year","Track_ID","Size","Total_Time","Disc_Number","Disc_Count","Track_Number","Track_Count","Bit_Rate","Sample_Rate","Play_Count","Rating","Normalization"} ;	
	
	private FrameDemo fd = null ;
	
	/**
	 * This is the default constructor
	 */
	public panelJulien(FrameDemo fd) {
		super();
		initialize();
		this.fd = fd ;
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		
		
		GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
		gridBagConstraints3.fill = GridBagConstraints.BOTH;
		gridBagConstraints3.gridy = 1;
		gridBagConstraints3.gridx = 1;
		
		gridBagConstraints3.weightx = 1.0;
		gridBagConstraints3.weighty = 1.0;
		
		GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
		gridBagConstraints2.fill = GridBagConstraints.BOTH;
		gridBagConstraints2.gridy = 0;
		gridBagConstraints2.weightx = 1.0;
		gridBagConstraints2.weighty = 1.0;
		gridBagConstraints2.gridx = 1;
		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
		gridBagConstraints1.gridx = 0;
		gridBagConstraints1.gridy = 1;
		jLabelOrdonnee = new JLabel();
		jLabelOrdonnee.setText("Ordonnees : ");
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		jLabelAbscisse = new JLabel();
		jLabelAbscisse.setText("Abscisse :");
		this.setSize(300, 200);
		this.setLayout(new GridBagLayout());
		this.add(jLabelAbscisse, gridBagConstraints);
		this.add(jLabelOrdonnee, gridBagConstraints1);
		this.add(getJListAbscisse(), gridBagConstraints2);
		this.add(getJListOrdonnee(), gridBagConstraints3);
		
		jListAbscisse.addActionListener(this);
		jListOrdonnee.addActionListener(this);
		
	}

	/**
	 * This method initializes jListAbscisse	
	 * 	
	 * @return javax.swing.JList	
	 */
	private JComboBox getJListAbscisse() {
		if (jListAbscisse == null) {
			jListAbscisse = new JComboBox(listeAbscisseValeurs);
			
		}
		return jListAbscisse;
	}
	
	private JComboBox getJListOrdonnee() {
		if (jListOrdonnee == null) {
			jListOrdonnee = new JComboBox(listeAbscisseOrdonnee);
			
		}
		return jListOrdonnee;
	}

	@Override
	public void actionPerformed(ActionEvent e) 
	{
        JComboBox cb = (JComboBox)e.getSource();
        String selected = (String)cb.getSelectedItem();
        
        if( cb == this .jListAbscisse )
        {
        	this.fd.getTabbedpanelDroite().getPanelCarre().selectionCritereAbcisse(selected);
        }
        else if ( cb == this .jListOrdonnee )
        {
        	this.fd.getTabbedpanelDroite().getPanelCarre().selectionCritereOrdonnee(selected);
        }
	}

	
	
}
